;
var _pageUrl = "/htmlWeb/evaluation/list";
function init() {
    _init_area();
    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY-MM-DD',
        // min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16', //最大日期
        istime: true,
        istoday: false,
        choose: function(datas){
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };

    var end = {
        elem: '#end',
        format: 'YYYY-MM-DD',
        max: '2099-06-16',
        event: 'click',
        istime: true,
        istoday: false,
        choose: function(datas){
            start.max = datas; //结束日选好后，充值开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
    $(".conBut").click(function () {
        var o = $("#searchForm").serializeSearchForm();
        if(o.start != undefined && o.start != null){
            o.start = date2timestamp(o.start+" 00:00:00");
        }if(o.end != undefined && o.end != null){
            o.end = date2timestamp(o.end+" 23:59:59");
        }
        pageGrid.search(o);
    });
}
var pageGrid;
function initPagerBar() {
    pageGrid = $("#pager").createPage({
        url: _pageUrl,
        ajaxBackFn: function (data) {
            var _gridHtml = '';
            $.each(data.rows, function (index, row) {
                _gridHtml += '<tr>' +
                    '<td><input type="hidden" class="rowid" value=\"' + row.id + '\"><p>' + row.id + '</p></td>' +
                    '<td><p>' + row.businessName + '</p></td>' +
                    '<td><p>' + (row.province == null ?  '' : row.province) + '</p></td>' +
                    '<td><p>' + (row.city == null ?  '' : row.city)+ '</p></td>' +
                    '<td><p>' + (row.district == null ?  '' : row.district) + '</p></td>' +
                    '<td><p>' + row.customName + '</p></td>' +
                    '<td><p>' + (row.customStar == 0 ?  '' : row.customStar) + '</p></td>' +
                    '<td><p>' + (row.customCommont == null ?  '' : row.customCommont) + '</p></td></tr>';
            });
            $("#evaluationGrid tr:not(:first)").html("");
            $('#evaluationGrid').append(_gridHtml);
        }
    });
}
/**
 * 时间字符串转时间戳
 * datestr: 2017-07-30 19:15:12
 */
var date2timestamp = function (datestr) {
    if(datestr == null) return;
    var timestamp2 = Date.parse(new Date(datestr));
    timestamp2 = timestamp2 / 1000;
    return timestamp2;
}
$(function () {
    init();
    initPagerBar();
});